/*     */ package com.newcrm.webapi.sub;
/*     */ 
/*     */ import com.newcrm.bean.CustomerSearchCondition;
/*     */ import com.newcrm.bean.User;
/*     */ import com.newcrm.db.CustomerManager;
/*     */ import com.newcrm.exception.NotFoundException;
/*     */ import com.newcrm.thread.DeleteCustomerThread;
/*     */ import com.newcrm.util.Util;
/*     */ import com.newcrm.webapi.AbstractAction;
/*     */ import com.newcrm.webapi.AbstractHttpServlet;
/*     */ import java.io.IOException;
/*     */ import java.io.PrintWriter;
/*     */ import javax.servlet.ServletException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import net.sf.json.JSONObject;
/*     */ import org.apache.log4j.Logger;
/*     */ 
/*     */ public class DeleteCustomers extends AbstractAction
/*     */ {
/*  25 */   private static Logger logger = Logger.getLogger(DeleteCustomers.class
/*  26 */     .getName());
/*     */ 
/*  28 */   private String indexPath = null;
/*     */ 
/*     */   public DeleteCustomers(AbstractHttpServlet servlet, String indexPath) {
/*  31 */     super(servlet);
/*  32 */     this.indexPath = indexPath;
/*     */   }
/*     */ 
/*     */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*     */     throws IOException, ServletException, NotFoundException
/*     */   {
/*  38 */     User loginUser = getLoginUser(request);
/*     */ 
/*  40 */     response.setContentType("text/html;charset=utf-8");
/*  41 */     PrintWriter out = response.getWriter();
/*  42 */     JSONObject jsonObject = new JSONObject();
/*     */ 
/*  45 */     if (!loginUser.isCanDelete()) {
/*  46 */       jsonObject.put("error", "1");
/*  47 */       out.println(jsonObject);
/*  48 */       out.flush();
/*  49 */       out.close();
/*  50 */       return;
/*     */     }
/*     */ 
/*  53 */     String customerIds = Util.getURLParameter(request
/*  54 */       .getParameter("CustomerIds"));
/*     */ 
/*  56 */     String selectAll = Util.getURLParameter(request
/*  57 */       .getParameter("selectAll"));
/*     */ 
/*  59 */     String ip = Util.getClientIpAddr(request);
/*     */ 
/*  61 */     logger.warn("ip:" + ip + " / 用户Id：" + loginUser.userId + " /  用户名：" + 
/*  62 */       loginUser.name + ", 删除了公司：id： " + customerIds);
/*     */ 
/*  65 */     if ("1".equals(selectAll))
/*     */     {
/*  67 */       CustomerSearchCondition searchCondition = new CustomerSearchCondition(
/*  68 */         request, loginUser, false);
/*     */ 
/*  70 */       logger.warn("全部选择删除条件：" + searchCondition.toString());
/*     */ 
/*  72 */       CustomerManager manager = new CustomerManager();
/*  73 */       int result = manager.deleteSelectAllCustomers(searchCondition, 
/*  74 */         loginUser);
/*     */ 
/*  77 */       new Thread(new DeleteCustomerThread(this.indexPath)).start();
/*     */ 
/*  79 */       jsonObject.put("error", "0");
/*  80 */       jsonObject.put("deleteNum", Integer.valueOf(result));
/*  81 */       out.println(jsonObject);
/*  82 */       out.flush();
/*  83 */       out.close();
/*  84 */       return;
/*     */     }
/*     */ 
/*  88 */     if ((customerIds == null) || (customerIds.trim().length() == 0)) {
/*  89 */       jsonObject.put("error", "1");
/*  90 */       out.println(jsonObject);
/*  91 */       out.flush();
/*  92 */       out.close();
/*  93 */       return;
/*     */     }
/*     */ 
/*  96 */     CustomerManager manager = new CustomerManager();
/*  97 */     int deleteNum = manager.deleteCustomers(customerIds, 
/*  98 */       loginUser.companyId, loginUser);
/*     */ 
/* 101 */     new Thread(new DeleteCustomerThread(this.indexPath)).start();
/*     */ 
/* 103 */     jsonObject.put("error", "0");
/* 104 */     jsonObject.put("deleteNum", Integer.valueOf(deleteNum));
/* 105 */     out.println(jsonObject);
/* 106 */     out.flush();
/* 107 */     out.close();
/*     */   }
/*     */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.DeleteCustomers
 * JD-Core Version:    0.6.1
 */